package DesignPattern.PrototypePattern.demo1;

import java.io.IOException;
import java.util.Date;

/**
 * Created by User on 2017/12/18.
 */
public class App {

    public static void main(String[] args) throws CloneNotSupportedException, IOException, ClassNotFoundException {

        DailyLog dailyLog = new DailyLog();
        dailyLog.setName("zql").setContent("hello prototype pattern");

        DailyLog dailyLogClone = dailyLog.clone();

        System.out.println(dailyLog == dailyLogClone);

        System.out.println(dailyLog.getName() == dailyLogClone.getName());
        System.out.println(dailyLog.getContent() == dailyLogClone.getContent());

        System.out.println("==========================================");

        WeeklyLog weeklyLog = new WeeklyLog();
        weeklyLog.setId(1L).setName("zql").setDate(new Date()).setContent("hello prototype pattern");

        WeeklyLog weeklyLogClone = weeklyLog.deepClone();

        // 获取hashcode方法被覆盖了的对象的hashcode
        System.out.println(System.identityHashCode(weeklyLog.getId()));
        System.out.println(System.identityHashCode(weeklyLogClone.getId()));

        System.out.println(weeklyLog == weeklyLogClone);

        System.out.println(weeklyLog.getId() == weeklyLogClone.getId());
        System.out.println(weeklyLog.getName() == weeklyLogClone.getName());
        System.out.println(weeklyLog.getDate() == weeklyLogClone.getDate());
        System.out.println(weeklyLog.getContent() == weeklyLogClone.getContent());


    }

}
